package com.share.dgs.config;

import com.share.dgs.instrumentation.CustomInstrumentation;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
import graphql.execution.instrumentation.tracing.TracingInstrumentation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;


/**
 * @author caifan
 * @created 2021/3/12
 * description:
 */
@Configuration
public class GraphQLConfig {

    /**
     * 类似spring AOP的功能
     * @return
     */
    @Bean
    @Primary
    public Instrumentation instrumentation() {
        Instrumentation instrumentation = new ChainedInstrumentation(
                new TracingInstrumentation(),
                new CustomInstrumentation(),
                new DataLoaderDispatcherInstrumentation());
        return instrumentation;
    }

}
